C (216/301)

From:Martyn Capewell
Date:05 Aug 99 at 17:18:57
Subject:Menus and Hooks

From: Martyn Capewell <martyn@jubileeweb.freeserve.co.uk>

Hello,

I've got a couple of questions, and wondered if someone here could help.

1. I'm using a NewMenu structure and CreateMenus(), LayoutMenus() to make
some menus, and I want to add some keyboard shortcuts for them. I've tried
using the nm_CommKey field of NewMenu, along with NM_COMMANDSTRING to do
this, but I can't see a way to add shortcuts like "<A> q" where <A> is the
Amiga key.
Is this the right way to do shortcuts? How can I add the <A> graphic?

2. I'm also using guigfx.library to display pictures on screen, and I'd
recommend it to anyone. However, I'd like to make a callback hook for it,
which would enable me to interupt rendering, but I can't manage to get it to
work.

First, I allocate enough memory for a new Hook structure:
if(!(hook = AllocMem(sizeof(struct Hook),MEMF_ANY | MEMF_CLEAR))) {...}

Then I try to initialise the Hook's fields:

InitHook(hook,(HOOKFUNC)abortdrawfunc(),NULL);

these are the function definitions:

VOID InitHook(struct Hook *hook, ULONG (*c_function)(), APTR userdata)
{
ULONG (*hookEntry)();

hook->h_Entry = hookEntry;
hook->h_SubEntry = c_function;
hook->h_Data = userdata;
}

ULONG __saveds abortdrawfunc(__reg("a0") struct Hook *hook)
{
return(TRUE);
}

I then pass the Hook to the DrawPicture() function of guigfx.library, which
results in a crash every time it tries to redraw.

I don't really understand the InitHook() function (It's taken from
<utility/hooks.h>) as it doesn't seem to initialise the h_Entry field.
Can anyone suggest how I should initialise the Hook structure?

I'm using VBCC, btw.

Thanks.



- Martyn Capewell
{ Compsci, University of Cambridge }
{ http://members.xoom.com/legerdemain0 }